{% extends 'blog/base.html' %}
{% load blog_tags %}
{% block title %}
  {{ post.title }}
{% endblock %}

{% block content %}
<h1>{{ post.title }}</h1>
<p>{{ post.published }} by {{ post.author }}</p>
<div>
  {{ post.body | markdown }}
</div>
<div>
  <p><a href="{% url "blog:post_share" post.id %}">Share this Post</a></p>
</div>
<div>
  {% for post in similar_posts %}
  <p><a href="{{ post.get_absolute_url }}"> {{ post.title }}</a><p>
  {% empty %}
  <p>There is no similar post.</p>
  {% endfor %}
</div>
<div>
    {% with comments.count as total_comments %}
    <h2>{{ total_comments }} comment {{ total_comments|pluralize }}</h2>
    {% endwith %}

    {% for comment in comments %}
    <div>
        <p>Comment {{ forloop.counter }} by {{ comment.name }} {{ comment.created }}</p>
        <p>{{ comment.body }}</p>
    </div>
    {% empty %}
        <p>There are no comments yet.</p>
    {% endfor %}
</div>
<div>
    <h2>Add a new comment</h2>
    <form action="." method="post" class="form-horizontal">{% csrf_token %}
      <div class="form-group">
           <label class="col-sm-2 control-label">name:</label>
           <div class="col-sm-10">{{ comment_form.name }}</div>
      </div>
      <div class="form-group">
           <label class="col-sm-2 control-label">comment:</label>
           <div class="col-sm-10">{{ comment_form.body }}</div>
      </div>
      <div class="form-group">
          <div class="col-sm-offset-2 col-sm-10">
            <input type="submit" value="ADD COMMENT">
        </div>
    </div>
    </form>
</div>
{% endblock %}
